package com.elin4it.blog.controller;

import com.elin4it.blog.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by allen on 15/7/30.
 */
@Controller
@RequestMapping("/contact")
public class ContactController {
    @Autowired
    private ConfigService configService;
    private final String flag = "contact";
    /**
     * 把一些公共的信息放入modelmap中
     *
     * @param map
     * @throws Exception
     */
    @ModelAttribute
    public void commonMessage(ModelMap map) throws Exception {
        //得到标题和副标题
        String title = configService.findTitle();
        String subTitle = configService.findSubTitle();

        //把标题和副标题放入到model中
        map.put("title", title);
        map.put("subtitle", subTitle);
        //设置页面标识
        map.put("flag",flag);
    }

    /**
     * 显示反馈内容表单
     * @return
     * @throws Exception
     */
    @RequestMapping("/contact")
    public String contact()throws Exception{


        return "contact/contact";
    }
}
